﻿Imports System.Data.OleDb
Imports System.Data
Public Class Forum
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

    End Sub

    Protected Sub Button1_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Button1.Click
        Dim myPath = Guid.NewGuid()
        Dim nwf As String = myPath.ToString() & ".jpg"
        Dim filelocationOnServerHarddisk = Request.MapPath("pictures/uploads/") & "/" & nwf
        Flup.SaveAs(filelocationOnServerHarddisk)

        Dim CONN As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("connectionstring").ConnectionString)
        Dim sqlstring As String = "insert into forum (username,brand, discuss,wine_image)values (@f1,@f2,@f3,@f4)"
        CONN.Open()
        Dim cmd As OleDbCommand = New OleDbCommand(sqlstring, CONN)
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", Tb_name.Text)
        cmd.Parameters.AddWithValue("@f2", Tb_bn.Text)
        cmd.Parameters.AddWithValue("@f3", Tb_d.Text)
        cmd.Parameters.AddWithValue("@f4", "pictures/uploads/" & nwf)
        cmd.ExecuteNonQuery()
        CONN.Close()
        Response.Redirect("Forum.aspx")

    End Sub

    Protected Sub Btn_Statistics_Click(ByVal sender As Object, ByVal e As EventArgs) Handles Btn_Statistics.Click
        Response.Redirect("WineStatictics.aspx")
    End Sub
End Class